home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Apple Guide / Engineering / Context Check Modules / Apple Extras CC / AppleExtras.c next >
Encoding:
C/C++ Source or Header  |  1994-04-26  |  1.5 KB  |  80 lines  |  [TEXT/KAHL]

  1. /****************************************/
  2.     
  3. /*    AppleExtras.c                        */
  4. /*    Author:             Shemin Gau, IP    */
  5. /*    Revision History:    04/05/94        */
  6.  
  7. /****************************************/
  8.  
  9.  
  10. #include <Files.h>
  11. #include <string.h>
  12. #include <Memory.h>
  13. #include <ToolUtils.h>
  14. #include <Errors.h>
  15. #include <Packages.h>
  16. #include <Types.h>
  17. #include <OSUtils.h>
  18.  
  19.  
  20. OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize);
  21.  
  22.  
  23. pascal OSErr main(Str255 msg, Size inSize, void* outMessage, Size* outSize, Handle ignoreMe)
  24. {    
  25.  
  26.     FInfo        fi;
  27.     char        *cDummy;
  28.     Str255        volName;
  29.     short         vRefNum;
  30.      long         freeBytes;
  31.     char        *ctemp;
  32.     StringPtr    ptemp;    
  33.     
  34.     Boolean        result = false;
  35.     OSErr        myErr = noErr;
  36.     
  37.  
  38.     // volName should be a pascal string pointer
  39.       if (GetVInfo(0, volName, &vRefNum, &freeBytes) == noErr) {
  40.           // be sure to use Str255 for c2pstr()
  41.            cDummy = p2cstr(volName);
  42.      }
  43.      else {
  44.         SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
  45.         return(1);
  46.       }
  47.       
  48.  
  49.     ctemp = p2cstr(msg);
  50.     strcat(cDummy, ctemp);
  51.     //now, convert the whole pathname into pascal string
  52.     ptemp = c2pstr(cDummy);
  53.         
  54.     if (GetFInfo(ptemp, 0, &fi) == noErr) {
  55.         result = true;
  56.     }
  57.     
  58.     myErr = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
  59.     return(myErr);
  60. }
  61.  
  62.  
  63. OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize)
  64. {
  65.     Ptr    p;
  66.     
  67.     if (p = NewPtr(theSize)) {
  68.         BlockMove(theData, p, theSize);
  69.         
  70.         *outSize = theSize;
  71.         *outMessage    = p;
  72.         
  73.         return(noErr);
  74.     } else {
  75.         return(MemError());
  76.     }
  77. }
  78.  
  79.  
  80.